#!/usr/bin/env bash
set -euo pipefail

export NAVI_HOME="$(cd "$(dirname "$0")/.." && pwd)"

cd "$NAVI_HOME"

if command_exists navi; then
   navi "$@"
elif [ -f "./target/release/navi" ]; then
   "./target/release/navi" "$@"
elif [ -f "./target/debug/navi" ]; then
   "./target/debug/navi" "$@"
else
   cargo run -- "$@"
fi
